{
	template:`
	<a-page-header title="编辑" sub-title="数据表">
		<template #extra>
			<a-button type="primary" @click="save();">保存</a-button>
			<m-back @click="back(false);">关闭</m-back>
		</template>
		<a-card :hoverable="true" :bodyStyle="{padding:'20px 20px 0'}">
			<a-form class="index-form" :wrapper-col="{span:24}">
				<a-row :gutter="10">
					<a-col :span="model.oid?24:8">
						<a-form-item label="来源" class="index-form-item">
							<a-radio-group v-if="!model.oid" :options="sourceOptions" v-model:value="model.source" />
							<div v-else>
                                <span v-if="model.source=='Y'"><a-tag color="processing">表</a-tag> {{model.sourceDesc}} {{model.sourceName}}</span>
                                <template v-else><a-tag color="processing">自建</a-tag> {{model.oid}}</template>
							</div>
						</a-form-item>
					</a-col>
					<a-col v-if="!model.oid&&model.source=='Y'" :span="16">
						<a-form-item label="来源表" class="index-form-item">
							<a-select :options="sourceList" v-model:value="model.sourceClass" @change="initMetaCol" placeholder="请选择来源表" show-search :filter-option="selectFilter" />
						</a-form-item>
					</a-col>
				</a-row>
				<a-row :gutter="10">
					<a-col :span="8">
						<a-form-item label="标识" class="index-form-item">
                            <a-tooltip title="只能输入小写字母数字和下划线">
                                <a-input v-model:value="model.name" placeholder="请输入标识" :disabled="model.oid"/>
							</a-tooltip>
						</a-form-item>
					</a-col>
					<a-col :span="16">
						<a-form-item label="描述" class="index-form-item">
							<a-input v-model:value="model.description" placeholder="请输入描述"/>
						</a-form-item>
					</a-col>
				</a-row>
			</a-form>
		</a-card>
	</a-page-header>
	<a-page-header v-if="model.source=='Y'&&metaCols.length" title="列" sub-title="明细" style="margin-top:-15px;">
		<a-card :hoverable="true" :bodyStyle="{padding:0}">
            <a-list size="small" :data-source="metaCols">
                <template #renderItem="{ item }">
                    <a-list-item>
                        <div style="flex:3;">{{item.name}}</div>
                        <div style="flex:4;">{{item.desc}}</div>
                        <template v-if="item.type">
                            <div style="flex:2;">{{item.type}}</div>
                            <div style="flex:1;">{{item.length}}</div>
                            <div style="flex:1;">{{item.defaultValue}}</div>
                            <div style="flex:1;">{{item.notnull}}</div>
                        </template>
                        <template v-else>
                            <div style="flex:4;">{{item.class}}</div>
                            <div style="flex:1;">{{item.notnull}}</div>
                        </template>
                    </a-list-item>
                </template>
            </a-list>
		</a-card>
	</a-page-header>
	<div id="apiTable_column" style="min-height:15px;margin-top:-15px;">
	</div>
	`,
	props: ['localeZh','param','parentVue'],
	data:function(){
		return {
		    model:{},
		    sourceOptions:[{label:'表',value:'Y'},{label:'自建',value:'N'}],
		    sourceList:[],
		    metaCols:[],
		};
	},
	mounted(){
	    this.model=this.param.model;
	    if(this.param.sourceList){
	        this.sourceList=this.param.sourceList;
	    }
        this.initColumn();
	},
	methods:{
		save:function(){
			this.requestData('action/api/apiTable/doSave',
				{model:this.model},
				data=>{
					if(data.code==0){
						this.$message.success(data.msg);
						this.model=data.model;
						this.setBack(true);
						this.initColumn();
					}else{
						this.$message.error(data.msg);
					}
				}
			);
		},
		initMetaCol:function(){
		    if(this.model.source=='Y'&&this.model.sourceClass){
		        this.requestData('action/api/apiColumn/getTableMetaColumn',
		            {tableClass:this.model.sourceClass},
		            data=>{
		                if(data.code==0){
		                    this.metaCols=data.list;
		                }else{
		                    this.$message.error(data.msg);
		                }
		            }
		        );
		    }else{
		        this.metaCols=[];
		    }
		},
		initColumn:function(){//初始化
			if(this.model.oid){
			    if(this.model.source=='Y'){
			        this.initMetaCol();
			    }else{
                    this.loadPage("apiTable_column",
                        "action/api/apiColumn/apiColumnList",
                        {params:{"table.oid":this.model.oid,"oper":"edit"}},
                        function(pv,v3){}.bind(this)
                    );
			    }
			}
		},
	}
}